#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <pthread.h>
#include <unistd.h>

int fd;

void *semafunc(void *arg)
{
    sleep(20);
    write(fd, "abc", 3);
    printf("%s: write ok!\n", __func__);
}

int main()
{
    fd = open("/dev/semaphore_app", O_RDWR);

    printf("fd = %d\n", fd);

    char buff[10];
    pthread_t pt;
    pthread_create(&pt, NULL, semafunc, NULL);

    read(fd, buff, 10);

    return 0;
}

